/**
 * Description:
 * Class Name:ReplaceTest
 * Date:2022/2/22 11:45
 *
 * @author LTisme
 * @version JAVA17
 */
package 疯狂Java讲义.第7章_Java基础类库._7_5_正则表达式._7_5_2_创建正则表达式;

import java.util.regex.*;

public class ReplaceTest {
    public static void main(String[] args) {
        String[] msgs = {
                "Java has regular expressions in 1.4",
                "regular expressions now expressing in Java",
                "Java expresses oracular expressions",
        };
        var p = Pattern.compile("re\\w*");
        Matcher matcher = null;
        for (int i = 0; i < msgs.length; i++) {
            if (matcher == null){
                matcher = p.matcher(msgs[i]);
            }
            else {
                matcher.reset(msgs[i]);
            }
            System.out.println(matcher.replaceAll("哈哈："));
        }
    }
}
